package com.wb.spring.boot.autoconfigure.utils;

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @Author deeprado
 * @Date 2022/8/31 15:01
 * <p>
 * 只解析对应接口
 */
public class InterfacePathScanningCandidateComponentProvider extends ClassPathScanningCandidateComponentProvider {
    public InterfacePathScanningCandidateComponentProvider(boolean useDefaultFilters) {
        super(useDefaultFilters);
    }

    @Override
    protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
        AnnotationMetadata metadata = beanDefinition.getMetadata();
        return metadata.isIndependent() && metadata.isInterface();
    }
}
